<%@ page language="java" contentType="text/html; charset=UTF-8"
		 pageEncoding="UTF-8"%>
<% 	String basePath = request.getScheme() + "://" +
		request.getServerName() + ":" + request.getServerPort() +
		request.getContextPath() + "/";
%>
<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>查询学生信息</title>
	<base href="<%=basePath%>">
	<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-3.4.1.js"></script>
	<script type="text/javascript">
		$(function () {
			loadStudentData();
			$("#btnLoader").click(function () {
				// alert("button click");
				loadStudentData();
			})
		})
		function loadStudentData() {
			$.ajax({
				url:"student/queryStudents.do",//这个是处理方法的地址
				type:"get",
				dataType:"json",
				success:function (resp) {
					$("#info").html("");
					$.each(resp,function (i,n) {
						$("#info").append("<tr>")
								.append("<td>"+n.id+"</td>")
								.append("<td>"+n.name+"</td>")
								.append("<td>"+n.age+"</td>")
								.append("</tr>")
					})
					/* alert("返回的文本数据："+resp); */
				}
			})
		}
	</script>
</head>
<body>
<div align="center">
	<table>
		<thead>
		<tr>
			<td>学号</td>
			<td>姓名</td>
			<td>年龄</td>
		</tr>
		</thead>
		<tbody id="info">

		</tbody>
	</table>
	<input type="button" id="btnLoader" value="查询数据">
</div>
</body>
</html>